//
//  IGRefundProofCell.m
//  jingdongfang
//
//  Created by MTiMac02 on 2018/1/24.
//  Copyright © 2018年 LJL. All rights reserved.
//

#import "IGRefundProofCell.h"
#import "SDPhotoBrowser.h"

@interface IGRefundProofCell()
{
    UILabel *proof;
    UIImageView *proofImage1;
    UIImageView *proofImage2;
    UIImageView *proofImage3;
    UITapGestureRecognizer *tap1;
    UITapGestureRecognizer *tap2;
    UITapGestureRecognizer *tap3;
}
@end
@implementation IGRefundProofCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];
    }
    return self;
}
- (void)createUI {
    self.contentView.backgroundColor = [UIColor c3Color];
    //凭证
    proof=[[UILabel alloc]initWithFrame:CGRectZero];
    proof.font=[UIFont font13];
    proof.textColor=[UIColor c5Color];
    [self.contentView addSubview:proof];
    //图片
    proofImage1=[[UIImageView alloc]init];
    proofImage2=[[UIImageView alloc]init];
    proofImage3=[[UIImageView alloc]init];
    proofImage1.userInteractionEnabled = YES;
     proofImage2.userInteractionEnabled = YES;
     proofImage3.userInteractionEnabled = YES;
    [self.contentView addSubview:proofImage1];
    [self.contentView addSubview:proofImage2];
    [self.contentView addSubview:proofImage3];
}
-(void)layoutSubviews{
    [super layoutSubviews];
    proof.text=NSLocalizedString(@"Voucher(s):", nil);
    proof.hidden=YES;
    [proof sizeToFit];
    CGFloat gap=(KSCREENWIDTH-GSCALE(300)-30)/2;
    proofImage1.frame=CGRectMake(15, 0, GSCALE(100), GSCALE(100));
    proofImage2.frame=CGRectMake(proofImage1.right+gap, 0, GSCALE(100), GSCALE(100));
    proofImage3.frame=CGRectMake(proofImage2.right+gap, 0, GSCALE(100), GSCALE(100));
    if (self.proofImg.count!=0) {
          proof.hidden=NO;
        if(self.proofImg.count==1)
        {
            [proofImage1 sd_setImageWithURL:self.proofImg[0]];
            tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(TapAction:)];
            [proofImage1 addGestureRecognizer:tap1];
        }
        if(self.proofImg.count==2)
        {
             [proofImage1 sd_setImageWithURL:self.proofImg[0]];
            tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(TapAction:)];
            [proofImage1 addGestureRecognizer:tap1];
            [proofImage2 sd_setImageWithURL:self.proofImg[1]];
            tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(TapAction:)];
            [proofImage2 addGestureRecognizer:tap2];
            proofImage3.hidden=YES;
        }
        if(self.proofImg.count==3)
        {
            [proofImage1 sd_setImageWithURL:self.proofImg[0]];
            tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(TapAction:)];
            [proofImage1 addGestureRecognizer:tap1];
            [proofImage2 sd_setImageWithURL:self.proofImg[1]];
            tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(TapAction:)];
            [proofImage2 addGestureRecognizer:tap2];
            [proofImage3 sd_setImageWithURL:self.proofImg[2]];
            tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(TapAction:)];
            [proofImage3 addGestureRecognizer:tap3];
        }
    }else{
        proof.hidden=YES;
        proofImage1.hidden=YES;
        proofImage2.hidden=YES;
        proofImage3.hidden=YES;
    }
    [self.contentView addSubview:proofImage1];
    [self.contentView addSubview:proofImage2];
    [self.contentView addSubview:proofImage3];
    proof.x=15;
    proof.y=0;
    proofImage1.y=proof.bottom+3;
    proofImage2.y=proof.bottom+3;
    proofImage3.y=proof.bottom+3;
}
- (void)TapAction:(UITapGestureRecognizer *)tap{
    __weak typeof(self) weakself = self;
    
    if (tap==tap1) {
        weakself.tagBlock(@"1001");
    }
    if (tap==tap2) {
        weakself.tagBlock(@"1002");
    }
    if (tap==tap3) {
        weakself.tagBlock(@"1003");
    }
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
